package com.cssw.fyzb.base.web.util;

import java.security.MessageDigest;

/**
 * @Author: chenchao
 * @Date: 2020/8/28 14:18
 */
public class MD5Util {

    public static String getMD5Str(String str) throws Exception {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(str.getBytes());
        byte b[] = md5.digest();

        int i;

        StringBuffer buf = new StringBuffer("");
        for (int offset = 0; offset < b.length; offset++) {
            i = b[offset];
            if (i < 0)
                i += 256;
            if (i < 16)
                buf.append("0");
            buf.append(Integer.toHexString(i));
        }


        return buf.toString();
    }


    public static void main(String[] args) throws Exception {
        long time = 1599387344350L;
        String str = "5S3Ra1SNrXEZpdku" + "&" + time + "&" + "5S3Ra1SNrXEZpdkuoSKs84EUMSoJyJm0";
        System.out.println("023b44021d1a8a02fe511bdd31703683".length());
        String result = MD5Util.getMD5Str(str);
        System.out.println(result);
        System.out.println(str.length());
        System.out.println(result.length());
    }


}
